package com.ricky;

import com.ricky.mq.client.connection.ClientConnection;
import com.ricky.mq.client.session.BoringSession;

/**
 * 测试监听消息类
 */
public class ListenerMsgTest01 {

    public static void main(String[] args) {
        /**
         * 创建连接器
         */
        ClientConnection connection = ClientConnection.getClientConnection()
                .ipAndPort("127.0.0.1", 2428)
                .sendModel(BoringSession.SYNC_MODEL)
                .readBufSize(65535)
                .waitTimeOut(6000)
                .heartbeatCheckTime(5)
                .connection();

        /**
         * 获取全局唯一session
         */
        BoringSession queueSession = connection.getBoringSession();

        queueSession.listenerQueueMessage("queue1", (boringMessage) -> {
            System.out.println("queue1-1" + boringMessage.getMessage());
        });

        queueSession.listenerTopicMessage("topic1", (boringMessage) -> {
            System.out.println("topic1-1" + boringMessage.getMessage());
        });
    }

}
